import {layoutRouteName,homeRouteName} from "./config"


/**
 * @description:系统布局初始化路由
 */
export const sysLayout_init_routes=[
  {
    path: '/',
    component:()=>import('@/layouts/BasicLayout.vue'),
    redirect:'/home',
    name:layoutRouteName,
    meta:{title:'系统布局',},
    children:[
      {
        path: 'home',
        name: homeRouteName,
        meta:{title:'首页',noInMenu:true,affix:true,icon:'home',rank:1},
        component: () => import('@/views/home.vue'),
      } as routeItemConfig,
    ]
  }
]

const sysLayout_constant_modules: Record<string, any> = import.meta.glob(
  ["./constant/**/*.ts",],
  {
    eager: true
  }
)
/**
 * @description:系统布局内部的常量路由，远程方案时会被引用。meta的那套规范依然适用，供开发者方便使用
 */
export const sysLayout_constant_routes=[] as routeItemConfig[]
Object.keys(sysLayout_constant_modules).forEach(key => {
  sysLayout_constant_routes.push(...sysLayout_constant_modules[key].default)
})


const sysLayout_modules: Record<string, any> = import.meta.glob(
  ["./modules/**/*.ts",],
  {
    eager: true
  }
)
/**
 * @description:系统布局内部的路由模块，远程方案时不会被引用。meta的那套规范依然适用，供开发者方便使用
 */
export const sysLayout_modules_routes = [] as routeItemConfig[];
Object.keys(sysLayout_modules).forEach(key => {
  sysLayout_modules_routes.push(...sysLayout_modules[key].default);
})


/**
 * @description:系统布局完整的路由配置
 */
export default[
  {
    ...sysLayout_init_routes[0] as any,
    children:[
      sysLayout_init_routes[0].children[0],
      ...sysLayout_modules_routes,
      ...sysLayout_constant_routes,
    ],
  } ,
] as routeItemConfig[]

